package com.bst.web.etl;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bst.common.annotation.Log;
import com.bst.common.enums.BusinessType;
import com.bst.etl.domain.EtlDrawBaseInter;
import com.bst.etl.service.IEtlDrawBaseInterService;
import com.bst.common.core.controller.BaseController;
import com.bst.common.core.domain.AjaxResult;
import com.bst.common.utils.poi.ExcelUtil;
import com.bst.common.core.page.TableDataInfo;

/**
 * 接口抽取Controller
 * 
 * @author ruoyi
 * @date 2024-03-18
 */
@Controller
@RequestMapping("/base/etl/inter")
public class EtlDrawBaseInterController extends BaseController
{
    private String prefix = "etl/base/inter";

    @Autowired
    private IEtlDrawBaseInterService etlDrawBaseInterService;

    @GetMapping()
    public String inter()
    {
        return prefix + "/base_inter";
    }

    /**
     * 查询接口抽取列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EtlDrawBaseInter etlDrawBaseInter)
    {
        startPage();
        List<EtlDrawBaseInter> list = etlDrawBaseInterService.selectEtlDrawBaseInterList(etlDrawBaseInter);
        return getDataTable(list);
    }

    /**
     * 导出接口抽取列表
     */
    @Log(title = "接口抽取", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EtlDrawBaseInter etlDrawBaseInter)
    {
        List<EtlDrawBaseInter> list = etlDrawBaseInterService.selectEtlDrawBaseInterList(etlDrawBaseInter);
        ExcelUtil<EtlDrawBaseInter> util = new ExcelUtil<EtlDrawBaseInter>(EtlDrawBaseInter.class);
        return util.exportExcel(list, "接口抽取数据");
    }

    /**
     * 新增接口抽取
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存接口抽取
     */
    @Log(title = "接口抽取", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(EtlDrawBaseInter etlDrawBaseInter)
    {
        return toAjax(etlDrawBaseInterService.insertEtlDrawBaseInter(etlDrawBaseInter));
    }

    /**
     * 修改接口抽取
     */
    @GetMapping("/edit/{idBaseInter}")
    public String edit(@PathVariable("idBaseInter") Long idBaseInter, ModelMap mmap)
    {
        EtlDrawBaseInter etlDrawBaseInter = etlDrawBaseInterService.selectEtlDrawBaseInterByIdBaseInter(idBaseInter);
        mmap.put("etlDrawBaseInter", etlDrawBaseInter);
        return prefix + "/edit";
    }

    /**
     * 修改保存接口抽取
     */
    @Log(title = "接口抽取", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(EtlDrawBaseInter etlDrawBaseInter)
    {
        return toAjax(etlDrawBaseInterService.updateEtlDrawBaseInter(etlDrawBaseInter));
    }

    /**
     * 删除接口抽取
     */
    @Log(title = "接口抽取", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(etlDrawBaseInterService.deleteEtlDrawBaseInterByIdBaseInters(ids));
    }
}
